<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文章详情 - TechShare</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/13.0.1/markdown-it.min.js"></script>
<script>
window.onload = function() {
const md = window.markdownit();
const content = document.getElementById('article-content');
if(content) {
const markdown = `
# TypeScript 4.5 新特性详解
## 1. 条件类型中的 tail-recursion 优化
TypeScript 4.5 优化了条件类型中的尾递归，这使得我们可以处理更深层次的递归而不会导致堆栈溢出。
\`\`\`typescript
type InfiniteList<T> = [T, ...InfiniteList<T>];
type Take<N extends number, T extends any[]> = T extends []
? []
: N extends 0
? []
: T extends [infer First, ...infer Rest]
? [First, ...Take<Subtract<N, 1>, Rest>]
: [];
\`\`\`
## 2. 新的装饰器语法
装饰器现在支持类字段和访问器：
\`\`\`typescript
class Example {
@log
private value: string;
@logAccess
get computedValue() {
return this.value.toUpperCase();
}
}
\`\`\`
## 3. 导入断言
现在可以在导入语句中使用类型断言：
\`\`\`typescript
import { something } from "./something.json" assert { type: "json" };
\`\`\`
## 4. 模板字符串类型改进
支持更复杂的模板字符串类型操作：
\`\`\`typescript
type Color = "red" | "blue";
type Quantity = "one" | "two";
type SemanticColors = \`\${Quantity}-\${Color}\`; // "one-red" | "one-blue" | "two-red" | "two-blue"
\`\`\`
## 5. 实践建议
1. 在大型项目中合理使用条件类型
2. 注意装饰器的性能影响
3. 使用模板字符串类型提高代码可维护性
## 总结
TypeScript 4.5 带来了多项重要更新，这些新特性将帮助我们编写更清晰、更可靠的代码。
### 代码示例
\`\`\`typescript
interface Config<T> {
data: T;
validate: (value: T) => boolean;
}
function createConfig<T>(config: Config<T>) {
return {
...config,
timestamp: new Date()
};
}
const numberConfig = createConfig({
data: 42,
validate: (n: number) => n > 0
});
\`\`\`
`;
content.innerHTML = md.render(markdown);
}
// 评论展开收起
const replies = document.querySelectorAll('.reply-toggle');
replies.forEach(reply => {
reply.addEventListener('click', function() {
const replyContent = this.nextElementSibling;
replyContent.classList.toggle('hidden');
});
});
}
</script>
<style>
.markdown-body {
font-size: 16px;
line-height: 1.6;
}
.markdown-body h1 {
font-size: 2em;
margin-bottom: 1em;
}
.markdown-body h2 {
font-size: 1.5em;
margin: 1em 0;
}
.markdown-body code {
background: #f6f8fa;
padding: 0.2em 0.4em;
border-radius: 3px;
}
.markdown-body pre {
background: #f6f8fa;
padding: 16px;
border-radius: 6px;
overflow-x: auto;
}
.toc-link.active {
color: #3B82F6;
font-weight: bold;
}
</style>
<style>
body {
min-height: 100vh;
background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
}
.hero-bg {
background-image: url('https://ai-public.mastergo.com/ai/img_res/18cc6a2adb2c3562e7a0c2773e8807b1.jpg');
background-size: cover;
background-position: center;
}
.article-card:hover {
transform: translateY(-4px);
transition: all 0.3s ease;
}
header {
transition: all 0.3s ease;
}
header.scrolled {
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
}
.logo-text {
font-family: 'Pacifico', serif;
background: linear-gradient(135deg, #3B82F6 0%, #10B981 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: gradient 3s ease infinite;
background-size: 200% 200%;
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
</style>
<script>
window.addEventListener('scroll', function() {
const header = document.querySelector('header');
if (window.scrollY > 50) {
header.classList.add('scrolled');
} else {
header.classList.remove('scrolled');
}
});
</script>
</head>
<body class="bg-gray-50">
<header class="fixed w-full bg-white shadow-sm z-50">
<div class="container mx-auto px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center">
<h1 class="text-3xl font-['Pacifico'] mr-12 logo-text">TechShare</h1>
<nav class="hidden md:flex space-x-8">
<a href="#" class="text-gray-800 hover:text-primary">首页</a>
<a href="#" class="text-gray-800 hover:text-primary">文章</a>
<a href="#" class="text-gray-800 hover:text-primary">教程</a>
<a href="#" class="text-gray-800 hover:text-primary">接单专区</a>
<a href="#" class="text-gray-800 hover:text-primary">关于我们</a>
</nav>
</div>
<div class="flex items-center space-x-6">
<div class="relative">
<input type="text" placeholder="搜索文章..." class="pl-10 pr-4 py-2 w-64 border border-gray-200 rounded-button focus:outline-none focus:border-primary">
<i class="fas fa-search absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
</div>
<button class="px-6 py-2 bg-primary text-white rounded-button hover:bg-blue-600 whitespace-nowrap">登录</button>
<button class="px-6 py-2 border border-primary text-primary rounded-button hover:bg-blue-50 whitespace-nowrap">注册</button>
</div>
</div>
</div>
</header>
<main class="min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 relative overflow-hidden">
<div class="absolute inset-0 bg-gradient-to-br from-blue-50 via-indigo-50 to-purple-50 animate-gradient"></div>
<div class="absolute inset-0">
  <div class="absolute top-10 left-10 w-20 h-20 bg-blue-400 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob"></div>
  <div class="absolute top-0 right-10 w-20 h-20 bg-purple-400 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob animation-delay-2000"></div>
  <div class="absolute -bottom-8 left-20 w-20 h-20 bg-pink-400 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob animation-delay-4000"></div>
</div>
<div class="max-w-md w-full relative">
<div class="text-center">
<h1 class="text-4xl font-['Pacifico'] mb-6 logo-text animate-text bg-gradient-to-r from-primary via-purple-500 to-blue-400 bg-clip-text text-transparent">TechShare</h1>
<h2 class="text-3xl font-bold text-gray-900 mb-8">欢迎回来</h2>
</div>
<div class="bg-white/80 backdrop-blur-lg p-8 rounded-lg shadow-2xl border border-white/50 hover:shadow-primary/20 transition-all duration-300">
<form class="space-y-6">
<div>
<label for="email" class="block text-sm font-medium text-gray-700 mb-1">邮箱地址</label>
<div class="relative">
<input id="email" name="email" type="email" required
class="appearance-none block w-full px-4 py-3 border border-gray-200 rounded-button placeholder-gray-400 bg-white/50 backdrop-blur focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition-all duration-300"
placeholder="请输入邮箱地址">
<i class="fas fa-envelope absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
</div>
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700 mb-1">密码</label>
<div class="relative">
<input id="password" name="password" type="password" required
class="appearance-none block w-full px-4 py-3 border border-gray-200 rounded-button placeholder-gray-400 bg-white/50 backdrop-blur focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition-all duration-300"
placeholder="请输入密码">
<i class="fas fa-lock absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
</div>
</div>
<div class="flex items-center justify-between">
<div class="flex items-center">
<input id="remember-me" name="remember-me" type="checkbox"
class="h-4 w-4 text-primary focus:ring-primary border-gray-300 rounded">
<label for="remember-me" class="ml-2 block text-sm text-gray-700">记住我</label>
</div>
<a href="#" class="text-sm text-primary hover:text-blue-600">忘记密码？</a>
</div>
<div>
<button type="submit" class="w-full py-3 px-4 border border-transparent rounded-button text-white bg-gradient-to-r from-primary to-blue-600 hover:from-blue-600 hover:to-primary transition-all duration-300 transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary whitespace-nowrap shadow-lg shadow-primary/30">
登录
</button>
</div>
<div class="relative">
<div class="absolute inset-0 flex items-center">
<div class="w-full border-t border-gray-200"></div>
</div>
<div class="relative flex justify-center text-sm">
<span class="px-2 bg-white text-gray-500">或</span>
</div>
</div>
<div class="grid grid-cols-3 gap-3">
<button type="button" class="flex justify-center items-center px-4 py-2 border-2 border-gray-200 rounded-button bg-white/50 backdrop-blur text-sm font-medium text-gray-700 hover:border-primary hover:text-primary transition-all duration-300 transform hover:scale-105 hover:shadow-lg hover:shadow-primary/20 whitespace-nowrap">
<i class="fab fa-github text-xl"></i>
</button>
<button type="button" class="flex justify-center items-center px-4 py-2 border-2 border-gray-200 rounded-button bg-white/50 backdrop-blur text-sm font-medium text-gray-700 hover:border-primary hover:text-primary transition-all duration-300 transform hover:scale-105 hover:shadow-lg hover:shadow-primary/20 whitespace-nowrap">
<i class="fab fa-google text-xl"></i>
</button>
<button type="button" class="flex justify-center items-center px-4 py-2 border-2 border-gray-200 rounded-button bg-white/50 backdrop-blur text-sm font-medium text-gray-700 hover:border-primary hover:text-primary transition-all duration-300 transform hover:scale-105 hover:shadow-lg hover:shadow-primary/20 whitespace-nowrap">
<i class="fab fa-weixin text-xl"></i>
</button>
</div>
<p class="text-center text-sm text-gray-600">
还没有账号？
<a href="#" class="font-medium text-primary hover:text-blue-600">立即注册</a>
</p>
</form>
</div>
</div>
</main>

</main>
<footer class="fixed bottom-0 w-full bg-transparent text-gray-600 py-4">
<div class="container mx-auto px-6 text-center text-sm">
<p>&copy; 2024 TechShare. All rights reserved.</p>
</div>
</footer>
<div class="container mx-auto px-6">
<div class="grid grid-cols-1 md:grid-cols-4 gap-12">
<div>
<h1 class="text-3xl font-['Pacifico'] mb-6 logo-text">TechShare</h1>
<p class="mb-4">分享技术，连接未来。在这里，与千万开发者一起成长。</p>
<div class="flex space-x-4">
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-github text-xl"></i></a>
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-twitter text-xl"></i></a>
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-linkedin text-xl"></i></a>
</div>
</div>
<div>
<h4 class="text-white text-lg font-bold mb-6">快速链接</h4>
<ul class="space-y-3">
<li><a href="#" class="hover:text-white">首页</a></li>
<li><a href="#" class="hover:text-white">文章</a></li>
<li><a href="#" class="hover:text-white">教程</a></li>
<li><a href="#" class="hover:text-white">接单专区</a></li>
</ul>
</div>
<div>
<h4 class="text-white text-lg font-bold mb-6">帮助支持</h4>
<ul class="space-y-3">
<li><a href="#" class="hover:text-white">帮助中心</a></li>
<li><a href="#" class="hover:text-white">联系我们</a></li>
<li><a href="#" class="hover:text-white">用户协议</a></li>
<li><a href="#" class="hover:text-white">隐私政策</a></li>
</ul>
</div>
<div>
<h4 class="text-white text-lg font-bold mb-6">联系我们</h4>
<ul class="space-y-3">
<li><i class="far fa-envelope mr-2"></i>contact@example.com</li>
<li><i class="far fa-phone mr-2"></i>400-123-4567</li>
<li><i class="far fa-map-marker-alt mr-2"></i>北京市朝阳区科技园区</li>
</ul>
</div>
</div>
<div class="border-t border-gray-800 mt-12 pt-8 text-center">
<p>&copy; 2024 博客平台. All rights reserved.</p>
</div>
</div>
</footer>
</body>
</html>
